<template>
	<view class="template-read tn-safe-area-inset-bottom">
		<view :class="show ? 'fade-in' : 'fade-out'">
			<view class="searchInput">
				<view class="input">
					<image :src="imgUrl.indexInput" mode=""></image>
					<input type="text" placeholder="请输入关键词搜索" v-model="searchKey" confirm-type="search"
						:adjust-position="true" :auto-blur="true" placeholder-class="pClass" @confirm="sousuo" />
				</view>
			</view>
			<view class="swiper" style="padding: 10px 15px;">
				<tn-swiper :list="swiperList" imageMode="aspectFill" @click="hpicto" :radius="15"
					:height="300"></tn-swiper>
			</view>
			<!-- 方式7 start-->
			<view class="tn-flex tn-flex-wrap tn-margin-sm">
				<view class=" tn-radius" v-for="(item, indexsdf) in iconnew" :key="indexsdf" style="width: 25%;">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center"
						@click="navigateToFn({ url: '/shopPages/list?id='+item.id, checkLogin: false })">
						<view class="icon7__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
							<image :src='item.image' class="type-img"></image>
						</view>
						<view class="tn-text-center ">
							<text class="tn-text-ellipsis type-name">{{item.title}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="nav_title">
				产 / 品
			</view>

			<!-- 图文 -->
			<!-- 比例 start-->
			<view class="tn-flex tn-flex-wrap  tn-padding-bottom">
				<block v-for="(item, index) in content" :key="index">
					<view class="" style="width: 50%;"
						@click="navigateToFn({ url: '/shopPages/product?id='+item.id, checkLogin: false })">
						<view class="tn-blogger-content__wrap">
							<view class="image-picbook">
								<view class="image-book">
									<image :src="item.images" style="width: 100%;height: 150px;border-radius: 7px;"
										mode="aspectFill"></image>
								</view>
							</view>

							<view class="tn-blogger-content__label tn-text-justify goods_name ">
								<text
									class="tn-blogger-content__label__desc  tn-text-ellipsis-2">{{ item.goods_name }}</text>
							</view>

							<view class="tn-flex  tn-flex-col-center tn-flex-row-between good-bom">
								<view class="">
									<text class="tn-blogger-content__count-icon fuhao">￥</text>
									<text class="tn-padding-right-sm tn-text-bold price">{{ item.price }}</text>
								</view>
								<text class="num">{{ item.buy_no }} 人购买</text>
							</view>



						</view>
					</view>
				</block>
			</view>
			<!-- 比例 end-->


			<view class="tn-padding-xl"></view>
		</view>
	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import NavIndexButton from '@/libs/components/nav-index-button.vue'
	export default {
		name: 'TemplateRead',
		mixins: [template_page_mixin],
		components: {
			NavIndexButton
		},
		data() {
			return {
				imgUrl: this.$imgs,
				searchKey: '',
				cardCur: 0,
				swiperList: [],
				content: [],
				iconnew: [],
				show: false
			}
		},
		onLoad() {
			this.info()
		},
		methods: {
			// cardSwiper
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},
			async info() {
				let that = this;
				let result = await that.$request({
					loading: 0,
					method: 'post',
					url: '/api/shop/index',
					data: {}
				});


				if (result.statusCode == 200) {
					if (result.data.code == 200) {

						that.swiperList = result.data.data.banner
						that.content = result.data.data.goods
						that.iconnew = result.data.data.cateshop
						that.show = true

					} else {
						uni.showToast({
							icon: 'none',
							title: result.data.msg
						});
					}
				} else {
					uni.showToast({
						icon: 'none',
						title: that.$errorMsg
					});
				}


			},

			sousuo() {
				if (this.searchKey == '') {
					this.msg('请输入关键词')
					return
				}
				uni.navigateTo({
					url: '/shopPages/list?searchKey=' + this.searchKey
				})
			},




			hpicto(index) {
				if (this.swiperList[index].url && this.swiperList[index].leixing == 0) {
					this.tn('/circlePages/details?id=' + this.swiperList[index].url + '')
				}
				if (this.swiperList[index].url && this.swiperList[index].leixing == 1) {
					this.tn('/circlePages/group?id=' + this.swiperList[index].url + '')
				}
				if (this.swiperList[index].url && this.swiperList[index].leixing == 2) {

					// #ifdef APP-PLUS
					this.navigateToFn({
						url: '/minePages/chat/room?id=' + this.swiperList[index].url,
						checkLogin: true
					})
					// #endif
					// #ifndef APP-PLUS
					this.navigateToFn({
						url: '/minePages/chat/room_text?id=' + this.swiperList[index].url,
						checkLogin: true
					})
					// #endif

				}
				if (this.swiperList[index].url && this.swiperList[index].leixing == 4) {
					this.tn('/shopPages/product?id=' + this.swiperList[index].url + '')
				}

			},
		}
	}
</script>
<style>
  page{
    background: #ffffff;
  }
</style>
<style lang="scss" scoped>

  .tn-text-center{
    padding: 10px 0;
  }
  .tn-margin-sm{
    padding-top: 20px;
    border-radius: 8px;
    background: #efefef;
    padding-bottom: 5px;
  }
	.type-img {
		width: 120rpx;
		height: 120rpx;
		margin-bottom: 16rpx;
	}

	.searchInput {
		height: 43px;
		display: flex;
		align-items: center;
		justify-content: center;
		position: sticky;
		/* #ifdef H5 */
		top: 44px;
		/* #endif */
		/* #ifndef H5 */
		top: 0;
		/* #endif */

		z-index: 10;
		//background-color: #111224;

		.input {
			width: 690rpx;
			height: 72rpx;
			background: #efefef;
			border-radius: 12rpx;
			padding: 0 24rpx;
			display: flex;
			align-items: center;

			image {
				width: 24rpx;
				height: 26rpx;
				margin-right: 16rpx;
			}

			input {
				color: $uni-text-color;
			}
		}

		.pClass {
			color: $uni-input-placeholder-color;
			font-size: 28rpx;
		}
	}

	.type-name {
		font-size: 26rpx;
		font-weight: 400;
		color: #333333;

	}



	.good-bom {
		padding: 0 20rpx 20rpx 20rpx;

		.fuhao {
			color: #FBE12B;
			font-size: 22rpx;
		}

		.price {
			color: #FBE12B;
			font-size: 30rpx;
		}

		.num {
			font-size: 24rpx;
			font-weight: 400;
			color: #CCCCCC;

		}
	}


	.logo-image {
		width: 65rpx;
		height: 65rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 50%;
	}

	/* 自定义导航栏内容 end */

	/* 轮播视觉差 start */
	.card-swiper {
		height: 400rpx !important;
	}

	.card-swiper swiper-item {
		width: 750rpx !important;
		left: 0rpx;
		box-sizing: border-box;
		padding: 0rpx 30rpx 90rpx 30rpx;
		overflow: initial;
	}

	.card-swiper swiper-item .swiper-item {
		width: 100%;
		display: block;
		height: 100%;
		border-radius: 30rpx;
		transform: scale(1);
		transition: all 0.2s ease-in 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item {
		transform: none;
		transition: all 0.2s ease-in 0s;
	}

	.card-swiper swiper-item .swiper-item-text {
		margin-top: -220rpx;
		width: 100%;
		display: block;
		height: 50%;
		border-radius: 10rpx;
		transform: translate(100rpx, -60rpx) scale(0.9, 0.9);
		transition: all 0.6s ease 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item-text {
		margin-top: -280rpx;
		width: 100%;
		transform: translate(0rpx, 0rpx) scale(0.9, 0.9);
		transition: all 0.6s ease 0s;
	}

	.image-banner {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.image-banner image {
		width: 100%;
		height: 100%;
	}

	/* 轮播指示点 start*/
	.indication {
		z-index: 9999;
		width: 100%;
		height: 36rpx;
		position: absolute;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.spot {
		background-color: #FFFFFF;
		opacity: 0.6;
		width: 10rpx;
		height: 10rpx;
		border-radius: 20rpx;
		top: -130rpx;
		margin: 0 8rpx !important;
		position: relative;
	}

	.spot.active {
		opacity: 1;
		width: 30rpx;
		background-color: #FFFFFF;
	}

	/* 图标容器7 start */
	.icon7 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 10rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 120rpx;
				height: 120rpx;
				font-size: 50rpx;
				border-radius: 0;
				margin-bottom: -10rpx;
				position: relative;
				z-index: 1;
			}
		}
	}

	.image-capsule {
		padding: 120rpx 0rpx;
		font-size: 40rpx;
		font-weight: 300;
		position: relative;
	}

	.image-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
	}

	/* 胶囊背景图 start */
	.image-div {
		height: 450rpx;
		z-index: -1;

		.image {
			width: 100%;
			height: 667rpx;
			// z-index: -1;
		}
	}

	.nav_title {
		font-size: 32rpx;
		font-weight: bold;
		color: #000000;
		text-align: center;
		margin-top: 40rpx;
		margin-bottom: 30rpx;
	}




	/* 标题 end */

	/* 文章内容 start*/
	.tn-blogger-content {
		&__wrap {
			box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.12);
			border-radius: 20rpx;
			margin: 15rpx;
		}

		&__info {
			&__btn {
				margin-right: -12rpx;
				opacity: 0.5;
			}
		}

		&__label {
			&__item {
				line-height: 45rpx;
				padding: 0 20rpx;
				margin: 5rpx 18rpx 0 0;

				&--prefix {
					color: #82B2FF;
					padding-right: 10rpx;
				}
			}

			&__desc {
				line-height: 35rpx;
			}
		}

		&__main-image {
			border-radius: 16rpx 16rpx 0 0;

			&--1 {
				max-width: 690rpx;
				min-width: 690rpx;
				max-height: 400rpx;
				min-height: 400rpx;
			}

			&--2 {
				max-width: 260rpx;
				max-height: 260rpx;
			}

			&--3 {
				height: 212rpx;
				width: 100%;
			}
		}

		&__count-icon {
			font-size: 30rpx;
			padding-right: 5rpx;
		}
	}

	.tn-blogger-content__wrap {
		background-color: #211C37;
	}

	.goods_name {
		font-size: 28rpx;
		font-weight: 400;
		color: #FFFFFF;
		padding: 20rpx;
	}

	.image-book {
		font-size: 16rpx;
		font-weight: 300;
		position: relative;
	}

	.image-picbook {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 20rpx 20rpx 0 0;
	}

	/* 文章内容 end*/

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		// margin: 20rpx;
		margin: 40rpx 5%;
		width: 90%;
		bottom: 0;
		z-index: 999;
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		overflow: initial;
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}
</style>
